#!/bin/bash
#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

HISTSIZE=2000
export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history:clear"
export HISTCONTROL=ignoreboth
export XDG_CONFIG_HOME=${HOME}/.config
# export VISUAL="nvim"
export FT2_SUBPIXEL_HINTING=1
stty -ixon

shopt -s autocd
shopt -s globstar
shopt -s checkwinsize

#PATH
PATH="$HOME/.npm/bin:$PATH"
PATH="$HOME/.local/bin:$PATH"
export NODE_PATH="$HOME/.npm/lib/node_modules"
export FZF_DEFAULT_OPTS='
--no-height
--bind ctrl-f:page-down,ctrl-b:page-up
--color=light,fg:232,bg:255,bg+:116,info:27
'

#thefuck
#eval "$(thefuck --alias)"

#alias
alias disk='df -hl'
alias sudo='sudo '
alias lm='ls -al'
alias ls='ls --color=auto -h --group-directories-first'
alias grep='grep --color=auto'
alias vi=vim
export PROMPT_COMMAND="history -a"
alias npm-exec='PATH=$(npm bin):$PATH'

trysource() {
  if [ -f "$1" ]; then
    source "$1"
  fi
}

if ! type _git >/dev/null 2>&1; then
  trysource "${HOME}/.git-completion.bash"
fi

trysource "${HOME}/.fzf.bash"
trysource "${HOME}/code/dotfiles/src/others.sh"
trysource "${HOME}/code/dotfiles/src/powerline.sh"
unset trysource

if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

# Save timestamp in the history file
HISTTIMEFORMAT="%F %T "
# Don't store duplicates
HISTCONTROL=ignoredups
# Allow "sharing" of history between instances
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"